﻿//using System;
//using System.Collections.Generic;
//using System.Data;
//using System.Threading.Tasks;
//using Dapper;

//namespace NiuX.Dapper.Dapper;

///// <summary>
///// Dapper 仓储实现类
///// </summary>
///// <typeparam name="TEntity"></typeparam>
//public partial class DapperRepository<TEntity> : Repositories.DapperRepository, IDapperRepository<TEntity>
//    where TEntity : class, new()
//{
//    /// <summary>
//    /// 构造函数
//    /// </summary>
//    /// <param name="serviceProvider"></param>
//    /// <param name="db"></param>
//    public DapperRepository(IServiceProvider serviceProvider
//        , IDbConnection db) : base(serviceProvider, db)
//    {
//    }

//    /// <summary>
//    /// 获取一条
//    /// </summary>
//    /// <param name="id"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual TEntity Get(object id, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.Get<TEntity>(id, transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 获取一条
//    /// </summary>
//    /// <param name="id"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual Task<TEntity> GetAsync(object id, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.GetAsync<TEntity>(id, transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 获取所有实体
//    /// </summary>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual IEnumerable<TEntity> GetAll(IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.GetAll<TEntity>(transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 获取所有实体
//    /// </summary>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual Task<IEnumerable<TEntity>> GetAllAsync(IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.GetAllAsync<TEntity>(transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 新增一条
//    /// </summary>
//    /// <param name="entity"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual long Insert(TEntity entity, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.Insert(entity, transaction, commandTimeout);
//    }


//    /// <summary>
//    /// 新增多条
//    /// </summary>
//    /// <param name="entities"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual long Insert(IEnumerable<TEntity> entities, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.Insert(entities, transaction, commandTimeout);
//    }



//    /// <summary>
//    /// 更新一条
//    /// </summary>
//    /// <param name="entity"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual bool Update(TEntity entity, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.Update(entity, transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 更新一条
//    /// </summary>
//    /// <param name="entity"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual Task<bool> UpdateAsync(TEntity entity, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.UpdateAsync(entity, transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 更新多条
//    /// </summary>
//    /// <param name="entities"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual bool Update(IEnumerable<TEntity> entities, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.Update(entities, transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 更新多条
//    /// </summary>
//    /// <param name="entities"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual Task<bool> UpdateAsync(IEnumerable<TEntity> entities, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.UpdateAsync(entities, transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 删除一条
//    /// </summary>
//    /// <param name="entity"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual bool Delete(TEntity entity, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return false;
//    }

//    /// <summary>
//    /// 删除一条
//    /// </summary>
//    /// <param name="entity"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual Task<bool> DeleteAsync(TEntity entity, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return false.ToTaskResult();
//    }

//    /// <summary>
//    /// 删除多条
//    /// </summary>
//    /// <param name="entities"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual bool Delete(IEnumerable<TEntity> entities, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.Delete(entities, transaction, commandTimeout);
//    }

//    /// <summary>
//    /// 删除多条
//    /// </summary>
//    /// <param name="entities"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <returns></returns>
//    public virtual Task<bool> DeleteAsync(IEnumerable<TEntity> entities, IDbTransaction transaction = null, int? commandTimeout = null)
//    {
//        return DbConnection.DeleteAsync(entities, transaction, commandTimeout);
//    }
//    /// <summary>
//    /// 查询返回特定类型
//    /// </summary>
//    /// <typeparam name="T"></typeparam>
//    /// <param name="sql"></param>
//    /// <param name="param"></param>
//    /// <param name="transaction"></param>
//    /// <param name="commandTimeout"></param>
//    /// <param name="commandType"></param>
//    /// <returns></returns>
//    public new virtual Task<IEnumerable<TEntity>> QueryAsync(string sql, object param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)
//    {
//        return DbConnection.QueryAsync<TEntity>(sql: sql, param, transaction, commandTimeout, commandType);
//    }
//}